Enable 64bit integer support on 32bit arch --enable-zend-int64 - #19079
Enable 64bit integer support on 32bit arch --enable-zend-int64#19079marc-mabe wants to merge 11 commits into
--enable-zend-int64#19079Conversation
|
I think this should go through the RFC process. There have been suggestions to drop 32-bit support, so I'm sure at least some people would object to expanding support further. I could see this as an alternative to dropping 32-bit support iff we also dropped 4-byte zend_long support, as that would align 32 and 64-bit. |
|
I have fixed some cases which failed due to SIZEOF_SIZE_T != SIZEOF_ZEND_LONG, but there are probably more. Currently, the test state is as follows: |
Yes, of course. At the current state I want to get to know the work needed to be done and do some benchmarks. For dropping 32-bit support entirely it seems to be to early at least for WebAssembly + there might be people hoping for supporting older (in some cases not that old) systems - so I don't thing it would go through currently. |
4fb8912 to
6b552c1
Compare
e28b737 to
f41823a
Compare
6baa1ec to
360cff4
Compare
|
The lower three bits of Bucket byte offset are used to store flags. If Bucket is aligned to 8 bytes, the lower three bits are always zero and this gives no problems. With the change of zend_long from 32 to 64 bits, the size of Bucket changed (to 28 bytes) and it is not aligned to 8 bytes anymore. The memory address and the flags overlap. Changing Bucket to be 32 bytes fixes things: The flags are ZEND_BIND_REF, ZEND_BIND_IMPLICIT, ZEND_BIND_EXPLICIT. They are stored here: opline->extended_value = (uint32_t)((char*)value - (char*)CG(active_op_array)->static_variables->arData) | mode;and extracted here: value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT))); |
In zend_compile.c, flags are stored in the lower bits of the Bucket address. If Bucket is aligned to 8 bytes, the lower three bits are always zero and this gives no problems. If the Bucket is not aligned, this results in non-obvious errors because the memory address and the flags overlap. This is difficult to debug when it happens, so add this assertion to make it more obvious what is wrong. The flags are ZEND_BIND_REF, ZEND_BIND_IMPLICIT, ZEND_BIND_EXPLICIT. Related to php#19079
In zend_compile.c, flags are stored in the lower bits of the Bucket address. If Bucket is aligned to 8 bytes, the lower three bits are always zero and this gives no problems. If the Bucket is not aligned, this results in non-obvious errors because the memory address and the flags overlap. This is difficult to debug when it happens, so add this assertion to make it more obvious what is wrong. The flags are ZEND_BIND_REF, ZEND_BIND_IMPLICIT, ZEND_BIND_EXPLICIT. Related to GH-19079
This PR allows to use 64bit integers on 32bit platforms if compiled with
--enable-zend-int64--enable-zend-int64)PHP_SYS_SIZE = [4|8])Zend/tests/andtests/ext/The main part is that
ZEND_ENABLE_ZVAL_LONG64 1gets defined.